import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;


public class ObjectSerializer extends TupleBinding{

	public Object entryToObject(TupleInput ti) {
		DataObject retVal = null;
		int objSize = ti.readInt();
		byte[] b = new byte[objSize];
		ti.read(b);
		retVal = new DataObject(b);		
		return retVal;
	}

	public void objectToEntry(Object object, TupleOutput to) {
		DataObject dob = (DataObject)object;
		to.writeInt(dob.getVal().length);
		to.write(dob.getVal());		
	}
}
